<?php

	require_once ("../../../system/framework.php");


	$order = $_REQUEST['order'];
	$orderField = $_REQUEST['orderfield']; 
    $table = $_REQUEST['table'];
	$arrayOrder = explode(",", $order);     



	for ($n = 0; $n < sizeof($arrayOrder); $n++) {
		
//		echo $arrayOrder[$n]."<br>";	
		$sql = "UPDATE $table SET $orderField=$n WHERE id=$arrayOrder[$n]";
		db::sqlExec($sql);
		
	}



/* This is where you would inject your sql into the database 
but we're just going to format it and send it back 
*/ 
/*foreach ($_GET['listItem'] as $position => $item) : 
  $sql[] = "UPDATE `table` SET `position` = $position WHERE `id` = $item"; 
endforeach; 
print_r ($sql); */


	//echo "gespeichert.";


?>